﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

#pragma warning disable CS8603 // 可能返回 null 引用。

namespace Hsenl.Network {
    public class MessagePool : ObjectPoolManager<DisposableMessage> {
        public override object Rent(Type type) {
            if (base.Rent(type) is DisposableMessage msg) {
                msg.IsCreateFromPool = true;
                return msg;
            }

            return false;
        }

        public override T Rent<T>() {
            var msg = base.Rent<T>();
            msg.IsCreateFromPool = true;
            return msg;
        }
    }
}